<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0" />
    <title>Document</title>
    <script src="/lib/vue.js"></script>
    <style>
      .active {
        background-color: red;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- in of没有区别 -->
      <input type="text" v-model="mytext" @input="changText" />
      <ul>
        <li
          v-for="(data,index) of datalist"
          :class="current==index?'active':''"
          @click="changColor(index)"
        >
          {{data}} ----{{index}}<button @click="delData(index)">del</button>
        </li>
      </ul>
      <ul>
        <li v-for="(data,key,index) of obj">{{key}}---{{data}}---{{index}}</li>
      </ul>
    </div>
    <script>
      var vm = new Vue({
        el: "#app",
        data() {
          return {
            datalist: ["首页", "购物车", "我的", "长平", "长征"],
            originlist: ["首页", "购物车", "我的", "长平", "长征"],
            current: 0,
            mytext: "",
          };
        },
        methods: {
          changText(evt) {
            this.datalist = this.originlist.filter((item) =>
              item.includes(evt.target.value)
            );
          },
        },
      });
    </script>
  </body>
</html>
